package com.zijie.members.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zijie.members.mapper.MemberAddressMapper;
import com.zijie.members.model.MembersAddress;
import com.zijie.members.model.search.MemberAddressSearchBean;
import com.zijie.members.service.MemberAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberAddressImpl implements MemberAddressService {

    private MemberAddressMapper memberAddressMapper;
    @Autowired
    public void setMemberAddressMapper(MemberAddressMapper memberAddressMapper) {
        this.memberAddressMapper = memberAddressMapper;
    }

    //查询全部：
    @Override
    public Page<MembersAddress> findAll(Page<MembersAddress> page, MemberAddressSearchBean memberAddressSearchBean) {
        return memberAddressMapper.findAll(page,memberAddressSearchBean);
    }

    //根据id删除
    @Override
    public int deleteById(Integer id) {
        return memberAddressMapper.deleteById(id);
    }


    @Override
    public boolean save(MembersAddress membersAddress) {
        return memberAddressMapper.insert(membersAddress)==1;
    }

    @Override
    public boolean update(MembersAddress membersAddress) {
        return memberAddressMapper.updateById(membersAddress)==1;
    }

    @Override
    public int deleteAll(List<Integer> ids) {
        return memberAddressMapper.deleteByIds(ids);
    }



    @Override
    public MembersAddress findByMemberId(Integer memberId) {
        return memberAddressMapper.selectById(memberId);
    }
}
